twoSampleProportionsTestDialog <- function(){
	initializeDialog(title=gettext("Two Proportions Test", domain="R-RcmdrPlugin.TeachingExtras"))
	onOK <- function(){
		freq1 <- tclvalue(freq1Variable)
		n1 <- tclvalue(size1Variable)
		freq2 <- tclvalue(freq2Variable)
		n2 <- tclvalue(size2Variable)
		alternative <- as.character(tclvalue(alternativeVariable))
		level <- tclvalue(confidenceLevel)
		test <- as.character(tclvalue(testVariable))
		closeDialog()
		if (test == "normal") doItAndPrint(paste("prop.test(c(", freq1, ",", freq2, "), c(", n1 , ",", n2, "), alternative='", alternative, "', conf.level=", level, ", correct=FALSE)", sep=""))
		else doItAndPrint(paste("prop.test(c(", freq1, ",", freq2, "), c(", n1 , ",", n2, "), alternative='", alternative, "', conf.level=", level, ", correct=TRUE)", sep=""))
		tkfocus(CommanderWindow())
	}
	OKCancelHelp(helpSubject="prop.test")
	freq1Frame <- tkframe(top)
	freq1Variable <- tclVar("")
	freq1Field <- ttkentry(freq1Frame, width="6", textvariable=freq1Variable)
	size1Variable <- tclVar("")
	size1Field <- ttkentry(freq1Frame, width="6", textvariable=size1Variable)
	freq2Frame <- tkframe(top)
	freq2Variable <- tclVar("")
	freq2Field <- ttkentry(freq2Frame, width="6", textvariable=freq2Variable)
	size2Variable <- tclVar("")
	size2Field <- ttkentry(freq2Frame, width="6", textvariable=size2Variable)
	radioButtons(name="alternative", buttons=c("twosided", "less", "greater"), values=c("two.sided", "less", "greater"),
			labels=gettextRcmdr(c("Two-sided", "Difference < 0", "Difference > 0")), title=gettextRcmdr("Alternative Hypothesis"))
	radioButtons(name="test", buttons=c("normal", "corrected"), 
			labels=gettextRcmdr(c("Normal approximation", "Normal approximation with\ncontinuity correction")), title=gettextRcmdr("Type of Test"))
	rightFrame <- tkframe(top)
	confidenceFrame <- tkframe(rightFrame)
	confidenceLevel <- tclVar(".95")
	confidenceField <- ttkentry(confidenceFrame, width="6", textvariable=confidenceLevel)
	tkgrid(labelRcmdr(freq1Frame, text=gettext("Sample frequency 1: ", domain="R-RcmdrPlugin.TeachingExtras"), fg="blue"), freq1Field, sticky="w")
	tkgrid(labelRcmdr(freq1Frame, text=gettext("Sample size 1: ", domain="R-RcmdrPlugin.TeachingExtras"), fg="blue"), size1Field, sticky="w")
	tkgrid(labelRcmdr(freq2Frame, text=gettext("Sample frequency 2: ", domain="R-RcmdrPlugin.TeachingExtras"), fg="blue"), freq2Field, sticky="w")
	tkgrid(labelRcmdr(freq2Frame, text=gettext("Sample size 2: ", domain="R-RcmdrPlugin.TeachingExtras"), fg="blue"), size2Field, sticky="w")
	tkgrid(freq1Frame, freq2Frame, sticky="nw")    
	tkgrid(labelRcmdr(confidenceFrame, text=gettextRcmdr("Confidence Level: "), fg="blue"), confidenceField, sticky="w")
	tkgrid(confidenceFrame, sticky="w")
	tkgrid(alternativeFrame, rightFrame, sticky="nw")
	tkgrid(testFrame, sticky="w")
	tkgrid(buttonsFrame, columnspan=2, sticky="w")
	tkgrid.configure(confidenceField, sticky="e")
	dialogSuffix(rows=5, columns=2)
}